import java.util.Arrays;

public class AG1 {

    public static void main(String[] args) {
        int[] arr = {2,7,9,3,1};
        int[][] dp = new int[arr.length][2];
        dp[0][1] = arr[0];
        //1 0 0 0
        for (int i = 1; i < dp.length; i++) {
            dp[i][1] = Math.max(dp[i - 1][4] + arr[i],dp[i - 1][1]);

            dp[i][0] = dp[i - 1][1];
        }
        System.out.println(Math.max(dp[dp.length - 1][1], dp[dp.length - 1][0]));
    }
}
